<#-- @ftlvariable name="entity" type="com.xci.platform.auth.entity.FeedbackEntity" -->
<#-- @ftlvariable name="authUser" type="com.xci.platform.auth.core.AuthUser" -->
<#include "/_inc/_layout.ftl">
<#include "/auth/feedback/_grid.ftl">
<@header/>
<div class="jxpanel jx-overflow-no winpanel" data-options="{fit:true}">
    <div class="jxtabs jxtabs-line" data-options="{fit:true}">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#tab-create" data-toggle="tab">反馈信息</a></li>
            <li><a href="#tab-list" data-toggle="tab">历史记录</a></li>
        </ul>
        <div class="tab-content">
            <div id="tab-create" class="tab-pane jx-overflow-auto fade in active">
                <form id="editform" class="jxform" method="post" data-protip="false" action="<@html.url "/auth/feedback/save"/>">
                    <input name="id" value="${entity.id!}" type="hidden">
                    <table class="table jxtable-form" style="width: 96%">
                        <tr>
                            <th class="w-100px">反馈类型</th>
                            <td>
                                <div class="input-group">
                                    <div class="icheck-inline">
                                        <label>
                                            <input type="radio" name="category" class="jxcheck" data-color="red" checked value="问题"> 问题
                                        </label>
                                        <label>
                                            <input type="radio" name="category" class="jxcheck" data-color="purple" value="优化"> 优化
                                        </label>
                                        <label>
                                            <input type="radio" name="category" class="jxcheck" data-color="green" value="新需求"> 新需求
                                        </label>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>反馈标题</th>
                            <td>
                                <input class="form-control" name="title" value="${entity.title!}" maxlength="100"
                                       data-validate="required: [true,'请输入反馈标题']" autocomplete="off"/>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="padding-left: 35px">
                                <textarea id="feedbackContent" name="feedbackContent" data-validate="required: [true,'请输入内容']"></textarea>
                            </td>
                        </tr>

                    </table>
                    <div class="tabpanel-footer text-right">
                        <button id="btnSave" class="btn btn-primary" type="button">
                            <i class="fa fa-save"></i> 反馈
                        </button>
                        <button id="btnCancel" class="btn btn-default" type="button" onclick="jx.closeDialog()">
                            <i class="fa fa-sign-in"></i> 取消
                        </button>
                    </div>
                </form>
            </div>
            <div id="tab-list" class="tab-pane jx-overflow-auto fade active">
                <@feedbacklist title="" operateUserId=authUser.userId/>
            </div>
        </div>
    </div>
</div>
<@footer>
    <@html.ueScript/>
    <script>
        function initUEditor() {
            var ops = $.extend({}, jx.auth.simpleUEOptions(), {initialFrameHeight: 250, serverUrl: '<@html.ueditorServerUrl/>'});
            UE.getEditor('feedbackContent', ops);
        }

        var $form = $('#editform');
        $form.on("beforesubmit", function () {
            var editor = UE.getEditor('feedbackContent');
            var content = editor.getPlainTxt().trim();
            if (content == '') {
                jx.toastr.error('请输入反馈内容');
                editor.focus();
                return false;
            }
            return true;
        }).on("aftersubmit", function (e, result) {
            if (result.success) {
                //jx.toastr.success('保存成功');
                jx.alert('感谢您的反馈！您的意见将成为我们改进产品，提升服务的重要依据，欢迎您继续关注支持我们。',function (index) {
                    jx.closeDialog(index);
                    $('.nav-tabs a:last').tab('show');
                    reloadGridData();
                });
            }
            else {
                jx.alert(result.message);
            }
        });

        $('#btnSave').click(function () {
            $form.jxform().submit();
        });

        initUEditor();
    </script>
    <script src="<@html.url '/auth/js/feedback.js'/>"></script>
</@footer>